<template>
  <v-card>
    <v-flex xs12 sm10>
      <v-tree url="/item/category/list"
              :isEdit="isEdit"
              @handleAdd="handleAdd"
              @handleEdit="handleEdit"
              @handleDelete="handleDelete"
              @handleClick="handleClick"
      />
    </v-flex>

  </v-card>
</template>

<script>



  export default {
    name: "category",

    data() {
      return {
        /*kai qi shu de bian ji gong neng */
        isEdit: true,
        add: false,
        show: false,
        categoryNode: {}
      }
    },
    methods: {
      handleAdd(node) {


        /*console.log("add .... ");
        console.log(node);
        // 发起请求
        this.$http.post("/item/category/add",{
          name:node.name,
          parentId:node.parentId,
          isParent:0,
          sort:node.sort
        })
          .then(function(resp){
            alert("添加成功！")
          })
          .catch(function(error){
            alert("添加失败")
          })*/

      },
      handleEdit(id,name) {
        console.log("edit... id: " + id + ", name: " + name);
      },
      handleDelete(id) {
        this.$http.delete("/item/category/delete", {
          params: {
            id: id
          }
        })
          .then(function (resp) {
          })// 成功时的回调
          .catch(function (error) {
          })// 失败时的回调
        console.log("delete ... " + id)
      },
      handleClick(node) {
        console.log(node)
      }
    }
  };
</script>

<style scoped>

</style>
